package com.wms.DB;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;

import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class DBBase {
	public static final String URL="jdbc:mysql://192.168.1.66:3306/wms1";
	public static final String USER="root";
	public static final String PASSWORD="123456";
	public static ResultSet result;
	
	public static void main(String[] args) throws Exception {
		DBBase.getReview_Id();
	}
	public static ResultSet ConnectDB(String sql) throws Exception {
		//1.加载驱动程序
		Class.forName("com.mysql.cj.jdbc.Driver");		
		//2.获取数据库连接
		Connection conn =DriverManager.getConnection(URL, USER, PASSWORD);
		//3.通过Connection对象创建Statement对象
		Statement stmt=conn.createStatement();
		//4.使用Statement执行SQL语句
		result=stmt.executeQuery(sql);
		return result;
	}
	
	public static void getReview_Id() throws Exception{
		result=DBBase.ConnectDB(sql.selectReview_id);
		List<String> review_id=new ArrayList<>();
		while(result.next()){						  
		  review_id.add(result.getString("review_id"));
		}
		if(review_id.size()>0){
			System.out.println(review_id);
			System.out.println(review_id.get(0));
		}else{
			System.out.println("null");
		}
	}
}



